/* toro_gen_header.h 
 * toro header for test verification

 * $Author: DIGI\sthurber $
 * $Date: 2007/07/30 22:59:49 $
 * $Name: Version1011 $
 */
 
//includes
#include "pub_def.h"
#include "board_config.h"

//Prototypes
void RadioInit(void);
void BoostPowerforTx(void);
void ReducePowerforRx(void);
void Init_Pot(void);
void POT_Write(UINT8);
//Defines
/* SARD */

#define ANTENNA_SWITCH
#define gTargetXBEE_d
#define LNA

/**************************************************************
SMAC Required defines
**************************************************************/
#define HCS08G																	 /*!<HCS06G family member*/
#define MC13192_CE              PTED_PTED2       /*!<Enables SPI transfers*/         
#define MC13192_CE_PORT         PTEDD_PTEDD2     /*!<SPI enable pin data direction*/

#define SIP (!PTAD_PTAD7)       // Indicates if using SIP or not.

// Transition transceiver from either Hibernate or Doze modes to Idle.
#define MC13192_ATTN            PTCD_PTCD2
#define MC13213_ATTN            PTDD_PTDD0
// ATTN pin data direction
#define MC13192_ATTN_PORT       PTCDD_PTCDD2
#define MC13213_ATTN_PORT       PTDDD_PTDDD0

// Enable transmission, reception, and CCA operations
#define MC13192_RTXEN           PTCD_PTCD3
#define MC13213_RTXEN           PTDD_PTDD1
// RTXEN pin direction
#define MC13192_RTXEN_PORT      PTCDD_PTCDD3
#define MC13213_RTXEN_PORT      PTDDD_PTDDD1

// Transceiver reset
#define MC13192_RESET           PTCD_PTCD4
#define MC13213_RESET           PTDD_PTDD3
// Reset pin direction
#define MC13192_RESET_PORT      PTCDD_PTCDD4
#define MC13213_RESET_PORT      PTDDD_PTDDD3
// Reset pin pull up enable
#define MC13192_RESET_PULLUP    PTCPE_PTCPE4
#define MC13213_RESET_PULLUP    PTDPE_PTDPE3

#define MC13192_IRQ_SOURCE      IRQSC						 /*!<IRQ register*/
#define MC13192_IRQ_IE_BIT      IRQSC_IRQIE			 /*!<Enables IRQ pin*/

#ifdef ANTENNA_SWITCH
    #define MC13192_ANT_CTRL        PTAD_PTAD2	 /*!<Control line 1 for antenna*/
    #define MC13192_ANT_CTRL2       PTCD_PTCD6   /*!< 
                                                  * Second Control line not
                                                  * used in MC13192EVB
                                                  */
    #define MC13192_ANT_CTRL_PORT   PTADD_PTADD2 /*!<Control line port data direction*/
    #define MC13192_ANT_CTRL2_PORT  PTCDD_PTCDD6 /*!< 
                                                  * Second Control line not 
                                                  * used in MC13192EVB
                                                  */
    #define ANT_CTRL_OFF            0       /*!<Antenna Control Logic low is off */
    #define ANT_CTRL_ON             1       /*!<Antenna Control Logic high is on */
#endif ANTENNA_SWITCH

#ifdef LNA    // Not needed for XBee     (shares with ANTENNA_SWITCH)
    #define MC13192_LNA_CTRL        PTCD_PTCD6		/*!<LNA Control*/
    #define MC13192_LNA_CTRL_PORT   PTCDD_PTCDD6  /*!<LNA control pin direction */
    #define LNA_ON                  1							/*!<Turns on LNA*/
    #define LNA_OFF                 0							/*!<Turns of LNA */
#endif LNA  

#define INIT_POT    0x96    // Initializes potentiometer




/**************************************************************
Enable peripherials that are on the Board
**************************************************************/
#define ACCEL_ENABLED         FALSE
#define TEMP_SENSOR_ENABLED   FALSE
#define BUZZER_ENABLED        FALSE
#define BUS_SPEED	            8000000

/**************************************************************
Define the SCI perameters
**************************************************************/
#define  SCIBDH     SCI1BDH
#define  SCIBDL     SCI1BDL
#define  SCIC1      SCI1C1 
#define  SCIC2      SCI1C2 
#define  SCIS1      SCI1S1 
#define  SCIS2      SCI1S2 
#define  SCIC3      SCI1C3 
#define  SCID       SCI1D

#define  SCIS1_TDRE  SCI1S1_TDRE
#define  SCIS1_TC    SCI1S1_TC

#define  RTS			PTAD_PTAD6
#define  RTSDIR		  	PTADD_PTADD6
#define  SCI_DEFAULT_BAUD  38400
#define  CTS      PTAD_PTAD0
#define  CTSDIR   PTADD_PTADD0
#define  CD       PTCD_PTCD5
#define  CDDIR    PTCDD_PTCDD5
/**************************************************************
Define the LED perameters
**************************************************************/

#define LED1                    PTCD_PTCD5
#define LED1DIR                 PTCDD_PTCDD5
#define LED2                    PTDD_PTDD1
#define LED2DIR                 PTDDD_PTDDD1
#define LED2_SIP                PTDD_PTDD6
#define LED2DIR_SIP             PTDDD_PTDDD6
#define LED3                    PTBD_PTBD4
#define LED3DIR                 PTBDD_PTBDD4
#define LED4                    PTBD_PTBD5
#define LED4DIR                 PTBDD_PTBDD5

/* Fifth LED is not defined for GB60EVB, set to Port D pin 5 */
#define LED5						  PTDD_PTDD5
#define LED5DIR                 PTDDD_PTDDD5
    
#define LED_ON                  0
#define LED_OFF       					1
#define DDIR_OUTPUT             1
#define DDIR_INPUT              0
    
#define LED_INIT_MACRO LED1     = LED_OFF; \
                       LED2     = LED_OFF; \
                       LED3     = LED_OFF; \
                       LED4     = LED_OFF; \
                       LED5     = LED_OFF; \
                       LED1DIR  = DDIR_OUTPUT; \
                       LED2DIR  = DDIR_OUTPUT; \
                       LED3DIR  = DDIR_OUTPUT; \
                       LED4DIR  = DDIR_OUTPUT; \
                       LED5DIR  = DDIR_OUTPUT;        
    
    
/***********************************************
Define Switches
***********************************************/
        
/* SW1 on schematic */
#define PB0 PTBD_PTBD0
#define PB0PU PTBPE_PTBPE0
#define PB0DIR PTBDD_PTBDD0
#define PB0IE KBI1PE_KBIPE2
  
/* SW2 on schematic */
#define PB1 PTBD_PTBD1
#define PB1PU PTBPE_PTBPE1
#define PB1DIR PTBDD_PTBDD1
#define PB1IE KBI1PE_KBIPE3
   
/* SW3 on schematic */
#define PB2 PTBD_PTBD2
#define PB2PU PTBPE_PTBPE2
#define PB2DIR PTBDD_PTBDD2
#define PB2IE KBI1PE_KBIPE4
  
/* SW4 on schematic */
#define PB3 PTBD_PTBD3
#define PB3PU PTBPE_PTBPE3
#define PB3DIR PTBDD_PTBDD3
#define PB3IE KBI1PE_KBIPE5

/* Define the KBI Pins */
#define KBI_SW1 0x04
#define KBI_SW2 0x08
#define KBI_SW3 0x10
#define KBI_SW4 0x20


#define SWITCH_INIT_MACRO    PB0PU = TRUE; \
                             PB1PU = TRUE; \
                             PB2PU = TRUE; \
                             PB3PU = TRUE; \
                             PB0DIR = FALSE;\
                             PB1DIR = FALSE;\
                             PB2DIR = FALSE;\
                             PB3DIR = FALSE;
                              
#define ENTER_LOW_POWER _asm stop


/***********************************************
Duplicate PB0 to PUSH_BUTTON1 etc for different
formats.
***********************************************/

#define PUSH_BUTTON1 PB0
#define PUSH_BUTTON2 PB1
#define PUSH_BUTTON3 PB2
#define PUSH_BUTTON4 PB3

#define PB_PRESSED 0
